package com.company.ems.controller;

import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

@WebServlet("/test-path")
public class TestPathServlet extends HttpServlet {
    
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) 
            throws ServletException, IOException {
        
        response.setContentType("text/html;charset=UTF-8");
        PrintWriter out = response.getWriter();
        
        out.println("<!DOCTYPE html>");
        out.println("<html>");
        out.println("<head>");
        out.println("<title>路径测试</title>");
        out.println("<meta charset='UTF-8'>");
        out.println("</head>");
        out.println("<body>");
        out.println("<h2>路径测试页面</h2>");
        out.println("<p>Context Path: " + request.getContextPath() + "</p>");
        out.println("<p>Servlet Path: " + request.getServletPath() + "</p>");
        out.println("<p>Path Info: " + request.getPathInfo() + "</p>");
        out.println("<p>Request URI: " + request.getRequestURI() + "</p>");
        out.println("<p>Request URL: " + request.getRequestURL() + "</p>");
        
        out.println("<h3>测试链接</h3>");
        out.println("<ul>");
        out.println("<li><a href='./employee/'>员工管理</a></li>");
        out.println("<li><a href='./employee/add'>添加员工</a></li>");
        out.println("<li><a href='./dashboard'>仪表板</a></li>");
        out.println("</ul>");
        
        out.println("</body>");
        out.println("</html>");
    }
}